# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoTaskAlertConfig do
  @moduledoc """
  Message to be used to configure alerting in the {@code TaskConfig} protos for tasks in an event.

  ## Attributes

  *   `aggregationPeriod` (*type:* `String.t`, *default:* `nil`) - The period over which the metric value should be aggregated and evaluated. Format is , where integer should be a positive integer and unit should be one of (s,m,h,d,w) meaning (second, minute, hour, day, week).
  *   `alertDisabled` (*type:* `boolean()`, *default:* `nil`) - Set to false by default. When set to true, the metrics are not aggregated or pushed to Monarch for this workflow alert.
  *   `alertName` (*type:* `String.t`, *default:* `nil`) - A name to identify this alert. This will be displayed in the alert subject. If set, this name should be unique in within the scope of the containing workflow.
  *   `clientId` (*type:* `String.t`, *default:* `nil`) - Client associated with this alert configuration. Must be a client enabled in one of the containing workflow's triggers.
  *   `durationThresholdMs` (*type:* `String.t`, *default:* `nil`) - Should be specified only for TASK_AVERAGE_DURATION and TASK_PERCENTILE_DURATION metrics. This member should be used to specify what duration value the metrics should exceed for the alert to trigger.
  *   `errorEnumList` (*type:* `GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigErrorEnumList.t`, *default:* `nil`) - 
  *   `metricType` (*type:* `String.t`, *default:* `nil`) - 
  *   `numAggregationPeriods` (*type:* `integer()`, *default:* `nil`) - For how many contiguous aggregation periods should the expected min or max be violated for the alert to be fired.
  *   `onlyFinalAttempt` (*type:* `boolean()`, *default:* `nil`) - Only count final task attempts, not retries.
  *   `playbookUrl` (*type:* `String.t`, *default:* `nil`) - Link to a playbook for resolving the issue that triggered this alert.
  *   `thresholdType` (*type:* `String.t`, *default:* `nil`) - The threshold type for which this alert is being configured. If value falls below expected_min or exceeds expected_max, an alert will be fired.
  *   `thresholdValue` (*type:* `GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigThresholdValue.t`, *default:* `nil`) - The metric value, above or below which the alert should be triggered.
  *   `warningEnumList` (*type:* `GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigErrorEnumList.t`, *default:* `nil`) - 
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :aggregationPeriod => String.t() | nil,
          :alertDisabled => boolean() | nil,
          :alertName => String.t() | nil,
          :clientId => String.t() | nil,
          :durationThresholdMs => String.t() | nil,
          :errorEnumList =>
            GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigErrorEnumList.t()
            | nil,
          :metricType => String.t() | nil,
          :numAggregationPeriods => integer() | nil,
          :onlyFinalAttempt => boolean() | nil,
          :playbookUrl => String.t() | nil,
          :thresholdType => String.t() | nil,
          :thresholdValue =>
            GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigThresholdValue.t()
            | nil,
          :warningEnumList =>
            GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigErrorEnumList.t()
            | nil
        }

  field(:aggregationPeriod)
  field(:alertDisabled)
  field(:alertName)
  field(:clientId)
  field(:durationThresholdMs)

  field(:errorEnumList,
    as:
      GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigErrorEnumList
  )

  field(:metricType)
  field(:numAggregationPeriods)
  field(:onlyFinalAttempt)
  field(:playbookUrl)
  field(:thresholdType)

  field(:thresholdValue,
    as:
      GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigThresholdValue
  )

  field(:warningEnumList,
    as:
      GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigErrorEnumList
  )
end

defimpl Poison.Decoder,
  for: GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoTaskAlertConfig do
  def decode(value, options) do
    GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoTaskAlertConfig.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoTaskAlertConfig do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
